package com.ss.android.article.base.feature.user.account.view;

import android.app.DatePickerDialog;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.bytedance.frameworks.base.mvp.Presenter;
import com.ss.android.account.b.c;
import com.ss.android.account.e.MuteQuickClickListener;
import com.ss.android.article.base.feature.user.account.presenter.AccountEditPresenter;
import com.ss.android.article.base.feature.user.location.ProvinceSelectedActivity;
import com.ss.android.article.base.ui.InputUserInfoDialog;
import com.ss.android.article.browser.R;
import com.ss.android.common.dialog.AlertDialog;

import java.util.Calendar;

final class b extends MuteQuickClickListener {
    protected final a b;

    b(a arg1) {
        this.b = arg1;
    }

    public final void doOnClick(View view) {
        String v0_3;
        a v1_2;
        String v2_1;
        AlertDialog.Builder v2;
        int v1 = 10;
        int v9 = 5;
        int v8 = 2;
        int v0 = view.getId();
        if(v0 == R.id.back) {
            if(this.b.getActivity() != null) {
                this.b.getActivity().onBackPressed();
            }
        }
        else if(v0 == R.id.ga) {
            Presenter v0_1 = a.a(this.b);
            ((AccountEditPresenter)v0_1).a("edit_profile", "account_setting_avatar");
            com.ss.android.account.b.b v0_2 = ((AccountEditPresenter)v0_1).g;
            String[] v1_1 = v0_2.b.getStringArray(R.array.a);
            v2 = com.ss.android.j.b.createDialogBuilder(v0_2.a);
            v2.setOnItemSelectedListener(((CharSequence[])v1_1), new c(v0_2));
            v2.show();
        }
        else if(v0 != R.id.gf) {
            if(v0 == R.id.gk) {
                a v3 = this.b;
                if(v3.getActivity() != null) {
                    v3.mPresenter.a("edit_profile", "account_setting_username");
                    if(v3.e == null) {
                        v3.e = new InputUserInfoDialog(v3.getActivity(), 0, v3.mPresenter.f);
                    }

                    v2_1 = v3.c.getText().toString();
                    InputUserInfoDialog v4 = v3.e;
                    v0 = v2_1.length() > v1 ? v2_1.length() : v1;
                    v4.a = v0;
                    v3.e.c(v3.getResources().getString(com.ss.android.article.browser.R.string.username_hint));
                    v3.e.d = v3.getString(com.ss.android.article.browser.R.string.account_modify_left_number);
                    v3.e.b(v2_1);
                    v3.e.h = new e(v3);
                    v3.e.a();
                }
            }
            else {
                if(v0 == R.id.gp) {
                    v1_2 = this.b;
                    if(v1_2.getActivity() == null) {
                        return;
                    }

                    if(v1_2.mPresenter.e == null) {
                        return;
                    }

                    v1_2.mPresenter.a("edit_profile", "account_setting_signature");
                    v0_3 = !TextUtils.isEmpty(v1_2.mPresenter.k) ? v1_2.mPresenter.k : v1_2.mPresenter.e.userDescription;
                    v2_1 = v0_3.replaceAll("\n", "").trim().replaceAll(" +", " ");
                    if(v1_2.d == null) {
                        v1_2.d = new InputUserInfoDialog(v1_2.getActivity(), 1, v1_2.mPresenter.f);
                    }

                    InputUserInfoDialog v3_1 = v1_2.d;
                    v0 = v2_1.length() > 30 ? v2_1.length() : 30;
                    v3_1.a = v0;
                    v1_2.d.c(v1_2.getResources().getString(com.ss.android.article.browser.R.string.input_introduce));
                    v1_2.d.d = v1_2.getString(com.ss.android.article.browser.R.string.account_left_number);
                    v1_2.d.b(v2_1);
                    v1_2.d.h = new f(v1_2);
                    v1_2.d.a();
                    return;
                }

                if(v0 == R.id.right_text) {
                    a.b(this.b).a("edit_profile", "submit");
                    a.a(this.b.getActivity(),
                            new com.ss.android.article.base.feature.user.account.view.c(this),
                            new com.ss.android.article.base.feature.user.account.view.d(this));
                    return;
                }

                if(v0 == R.id.gw) {
                    v1_2 = this.b;
                    v0_3 = !TextUtils.isEmpty(v1_2.mPresenter.l) ? v1_2.mPresenter.l : String.valueOf(v1_2.mPresenter.e.userGender);
                    if("1".equals(v0_3)) {
                        v0 = 0;
                    }
                    else if("2".equals(v0_3)) {
                        v0 = 1;
                    }
                    else {
                        v0 = 0;
                    }

                    v2 = com.ss.android.j.b.createDialogBuilder(v1_2.getContext());
                    v2.setSingleChoiceItems(R.array.a8, v0, new i(v1_2));
                    v2.setCancelable(true);
                    v2.setNegativeButton(com.ss.android.article.browser.R.string.cancel, null);
                    v2.show();
                    return;
                }

                if(v0 == R.id.h1) {
                    a v7 = this.b;
                    v0_3 = !TextUtils.isEmpty(v7.mPresenter.m) ? v7.mPresenter.m : v7.mPresenter.e.userBirthday;
                    Calendar v1_3 = Calendar.getInstance();
                    int v3_2 = v1_3.get(1);
                    int v4_1 = v1_3.get(v8);
                    int v5 = v1_3.get(v9);
                    if(android.support.design.a.q(v0_3)) {
                        v3_2 = android.support.design.a.a(v0_3, 1);
                        v4_1 = android.support.design.a.a(v0_3, v8);
                        v5 = android.support.design.a.a(v0_3, v9);
                    }

                    DatePickerDialog v0_4 = new DatePickerDialog(v7.getContext(), new j(v7), v3_2, v4_1, v5);
                    v0_4.setCancelable(true);
                    v0_4.show();
                    return;
                }

                if(v0 != R.id.h6) {
                    return;
                }

                this.b.startActivityForResult(new Intent(this.b.getActivity(), ProvinceSelectedActivity.class), 110);
            }
        }
    }
}

